package org.codeart.juc.queue;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;

public class ArrayBlockingQueueTest {

    public static void main(String[] args) throws InterruptedException {
        ArrayBlockingQueue<Integer> queue = new ArrayBlockingQueue<>(3);
        // add方法会抛异常
        queue.add(1);
        queue.add(2);
        queue.add(3);
        // 添加失败
        queue.offer(4, 2, TimeUnit.SECONDS);
        System.out.println(queue);
        // 对头元素出队
        System.out.println(queue.remove());
        System.out.println(queue.poll());
        System.out.println(queue.take());
    }

}
